<template>
  <div>

    <el-table :data="dataList" v-loading="loading" style="width: 100%;margin-top: 20px;" border>
      <el-table-column label="型号">
        <template slot-scope="scope">
          {{ scope.row.model_number?scope.row.model_number.model_number:'' }}
        </template>
      </el-table-column>
      
      <el-table-column label="数量">
        <template slot-scope="scope">
          {{ scope.row.count }}
        </template>
      </el-table-column>
      <el-table-column label="操作" width="100">
        <template slot-scope="scope">
          <el-button slot="reference" type="tetx"  @click="push_yanse(scope.row.model_number_id)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        background
        @prev-click="prev"
        @next-click="next"
        :current-page.sync="pagination.page"
        :page-size="pagination.per_page"
        layout="total, prev, pager, next"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import {
  getSemiFinishProductInfo
} from "@/api/product/index";
export default {
  data() {
    return {

      loading: true,
      dataList: [],
      pagination: {
        per_page: 10,
        page: 1,
      },
      total: 0,
      warehouse_id:'',
      product_id:''
    };
  },
  mounted() {
    this.warehouse_id=this.$route.query.data
    this.product_id=this.$route.query.product_id
    this.getlist(this.$route.query.data,this.$route.query.product_id);
  },
  methods: {
    push_yanse(id){
      this.$router.push({
        name: "index_more_yanse",
        path: "/index_more_yanse",
        query:{
          data:this.warehouse_id,
          product_id:this.product_id,
          model_number_id:id
        }
      });
    },
    getlist() {
      getSemiFinishProductInfo({page_name:'model_number',warehouse_id:this.warehouse_id,product_id:this.product_id,...this.pagination}).then((res) => {
        if (res.code == 200) {
          this.dataList = res.data.data;
          this.total = res.data.total;
          this.loading = false;
        }
      });
    },
    handleSizeChange(val) {
      console.log(val);
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pagination.page = val;
      this.getlist();
    },
    prev() {
      this.pagination.page = this.pagination.page - 1;
      this.getlist();
    },
    next() {
      console.log("ss");
      this.pagination.page = this.pagination.page + 1;
      this.getlist();
    },
  },
};
</script>

<style scoped>
.d {
  color: black !important;
}
.el-table{
  margin-top:0px;
}
</style>
